#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> countBits(int n) {
        vector<int> v;

        int temp = 0;
        while (temp <= n)
        {
            int count = 0;
            int a = temp;
            while (a > 0)
            {
                if (a & 1 == 1)
                    count++;
                a >>= 1;
            }
            //cout<<"sss"<<endl;
            v.push_back(count);
            temp++;
        }
        return v;
    }
};